package com.zlm.common.constants;

import java.util.HashMap;
import java.util.Map;

public class FileConstants {

    public static Map<String, String> map = new HashMap<>();
    public static Map<String, Integer> mapType = new HashMap<>();

    /**
     * 头像
     */
    public final static String HEADER_IMG = "header";

    /**
     * 身份证
     */
    public final static String ID_CARD = "idcard";

    /**
     * 体检报告
     */
    public final static String HEALTH = "health";

    /**
     * 表示图片
     */
    public final static Integer IMAGES = 1;

    /**
     * 表示文档
     */
    public final static Integer DOCS = 2;

    /**
     * 表示视频
     */
    public final static Integer VIDIOS = 3;

    /**
     * 表示种子
     */
    public final static Integer TOTTENTS = 4;

    /**
     * 表示音乐
     */
    public final static Integer MUSICS = 5;

    /**
     * 表示其它
     */
    public final static Integer OTHERS = 6;

    /**
     * 文件上传根路径
     */
    public final static String ROOT_PATH = "/home/image";
//    public final static String ROOT_PATH = "c:/home/image";
    public final static String SEPARATOR = "/";


    /**
     * 静态块，类加载的时候执行，且仅执行一次
     */
    static {
        //头像目录
        map.put(HEADER_IMG, "/emp/header/");
        map.put(ID_CARD, "/emp/idcard/");
        map.put(HEALTH, "/emp/health/");

        mapType.put(HEADER_IMG, IMAGES);
        mapType.put(ID_CARD, IMAGES);
        mapType.put(HEALTH, IMAGES);
    }

    /**
     * 根据fileType获取path
     * @param uploadType 上传类型
     * @return
     */
    public static String getPath(String uploadType) {
        String path = map.get(uploadType);
        if (path == null) {
            //临时目录
            path = "/tmp/";
        }

        return path;
    }

    /**
     * 根据fileType获取文件类型
     * @param uploadType
     * @return
     */
    public static Integer getType(String uploadType) {
        Integer type = mapType.get(uploadType);
        if (type == null) {
            type = OTHERS;
        }

        return type;
    }

}
